package com.epam.DAO.impl;

import java.util.List;

import javax.ejb.Stateless;
import javax.interceptor.Interceptors;
import javax.persistence.TypedQuery;

import com.epam.DAO.CarDAO;
import com.epam.entity.Car;
import com.epam.utils.Interceptor;

@Interceptors(Interceptor.class)
@Stateless
public class CarDAOImpl extends GenericDAOImpl<Car> implements CarDAO {

	public CarDAOImpl() {
		super(Car.class);
	}

	@Override
	public List<Car> getAvaliableCars() {
		TypedQuery<Car> query = em.createQuery(
				"SELECT c FROM Car c WHERE c.isAvaliable = true", Car.class);
		List<Car> list = query.getResultList();
		return list;
	}

}